package edu.ccut.saturn.manager.bundles.core;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import edu.ccut.saturn.component.DefaultComponent;
import edu.ccut.saturn.component.IParameterContext;
import edu.ccut.saturn.component.IParameterInfo;

public class BundleListToMapList extends DefaultComponent {
	@Override
	public void execute(IParameterContext parameterContext) throws Exception {
		
		List<IParameterInfo> list = (List<IParameterInfo>)parameterContext.getParameterValue(0);
		
		List<Map<String, Object>> result = new ArrayList<Map<String,Object>>();
		
		if(list != null){
			
			for(IParameterInfo parameterInfo: list){
				
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("id", parameterInfo.getId());
				map.put("name", parameterInfo.getName());
				map.put("valueKey", parameterInfo.getValueKey());
				map.put("classType", parameterInfo.getClassType());
				map.put("passingType", parameterInfo.getPassingType());
				
				result.add(map);
			}
		}
		
		parameterContext.setParameter(1, result);
	}
}